home *** CD-ROM | disk | FTP | other *** search
- ======================================
- DOS & Don'ts -- Part 38
-
- by James Gregory Weiler
- ======================================
-
- Section 2: Relative files
-
-
- Surprise! The structure of RELative
-
- files is almost exactly the same as
-
- any other file type. Yes, you can
-
- start at the BAM, link through the
-
- directory, and then link from one data
-
- block to the next until you find the
-
- end of the file. The links work the
-
- same old way, and the data is stored
-
- the same old places, just as described
-
- in map 6 in Part 37.
-
- What makes relative files special is
-
- the way you can directly access any
-
- piece of data out in the middle of the
-
- file without bothering to read any of
-
- the intervening data. In other words,
-
- you don't have to follow the file
-
- links to find a given block of a
-
- relative file.
-
- Well, all good things have a price,
-
- and the price of relative files is
-
- a beastie called the "side sector".
-
- In essence, side sectors keep track
-
- of exactly where on the disk any
-
- given block of a relative file can
-
- be found. DOS uses side sectors as a
-
- "short-cut" to the record you want in
-
- a relative file.
-
- You remember from our discussion of
-
- the directory that a file name entry
-
- for a relative file has a link to
-
- the first file block and a link to the
-
- first side sector block. In essence,
-
- each relative file is two linked
-
- files -- a data file made up of
-
- ordinary data blocks, and an index
-
- file built out of side sectors.
-
- Here's a chart of relative file
-
- organization. I hope you can
-
- understand it.
-
- {CBM-A}------------------------------{CBM-S}
- !Relative file directory entry.!
- {CBM-Z}------{CBM-R}----------{CBM-R}------------{CBM-X}
- V V
- {CBM-A}--{CBM-E}---{CBM-S} {CBM-A}-{CBM-E}----{CBM-S}
- u !side {CBM-Q}--> !data !
- n{CBM-A}-->!sector{CBM-Q}--> !blocks!
- i! !# 1 {CBM-Q}--> !1-120 !
- v! {CBM-Z}--{CBM-R}---{CBM-X} {CBM-Z}-{CBM-R}----{CBM-X}
- e! V V
- r! {CBM-A}--{CBM-E}---{CBM-S} {CBM-A}-{CBM-E}-----{CBM-S}
- s! !side {CBM-Q}--> !data !
- a{CBM-Q}-->!sector{CBM-Q}--> !blocks !
- l! !# 2 {CBM-Q}--> !121-240!
- ! {CBM-Z}--{CBM-R}---{CBM-X} {CBM-Z}-{CBM-R}-----{CBM-X}
- l! V V
- i! {CBM-A}--{CBM-E}---{CBM-S} {CBM-A}-{CBM-E}-----{CBM-S}
- n! !side {CBM-Q}--> !data !
- k{CBM-Z}-->!sector{CBM-Q}--> !blocks !
- !# 3 {CBM-Q}--> !241-360!
- {CBM-Z}------{CBM-X} {CBM-Z}-------{CBM-X}
-
-
- Each square on the left is a single
-
- block. Each square on the right is
-
- 120 blocks. The arrows are links.
-
- The universal link on the left links
-
- each side sector to every other side
-
- sector.
-
- Now, let's see how DOS follows the
-
- links to read data block 259.
-
- a) Read BAM - link to directory.
- b) Read directory - link to side
- sector 1.
- c) Read side sector 1 - link to
- side sector 3.
- d) Read side sector 3 - link to
- data block 259.
-
- Hmmm. DOS only had to read four
-
- blocks. If it was trying to find
-
- block 259 of a SEQ file it would have
-
- to read all 258 of the preceding data
-
- blocks.
-
- =======< continued in Part 39 >=======
-